<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePersonsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
      Schema::create('persons', function(Blueprint $table)
      {
          // 创建字段
          $table->increments('id');                // ID
          $table->string('name', 50);                  // 姓名
          $table->string('avatar', 100);                //  头像
          $table->string('id_number', 30);             // 身份证
          $table->string('reg_addr', 100);              // 户籍地
          $table->string('temp_addr', 100);             // 暂住地
          $table->integer("five_saw_time");        // 到我市时间
          $table->integer("leave_time");        // 离开我市时间
          $table->string('meet_situation', 255);   // 见面情况
          $table->string('remark', 255);   // 我市活动情况
          $table->integer('is_the_city', 1);   // 本市
          $table->string('phone', 50);             // 手机号
          $table->string('qq', 20);                // QQ
          $table->string('weixin', 20);            // 微信
          $table->integer('user_id');              // 添加人id
          $table->timestamp('created_at')->nullable();
          $table->timestamp('updated_at')->nullable();
          $table->integer('is_deleted', 1);

          // 创建索引
          $table->unique(['id', 'is_deleted']);
          $table->unique(['is_deleted', 'id']);
          $table->index(['created_at', 'is_deleted']);
          $table->index(['five_saw_time', 'leave_time', 'is_the_city', 'is_deleted', 'id']);
      });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
